package main

import (
	"bytes"
	"fmt"
)

func main() {
	s := "ab"
	//reverseStr("ab")
	str := getReverseStr(s, 2)
	fmt.Println(str)
}

func getReverseStr(s string, k int) string {

	count := bytes.Count([]byte(s), nil)
	if count <= k {
		return reverseStr(s)
	}

	return reverseStr(s[0:k]) + s[k:count-1]
}

func reverseStr(s string) string {
	count := bytes.Count([]byte(s), nil) - 1
	temp := ""
	for i := 0; i <= count; i++ {

		temp += s[count-1 : count]

		count--
	}
	return temp
}
